package com.icode.translate;

import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

/**
 * Created with IntelliJ IDEA.
 * User: alexz
 * Date: 14-7-4
 * Time: 下午4:55
 * To change this template use File | Settings | File Templates.
 */
@Endpoint
public class TranslatorEndpoint {

    private Translatable translator = new SimpleTranslator();

    @PayloadRoot(namespace = "", localPart = "")
    @ResponsePayload
    public TranslateResponse getTranslateResponse(@RequestPayload TranslateRequest translateRequest) {
        TranslateResponse translateResponse = new TranslateResponse();
        translateResponse.setResult(translator.translate(translateRequest.getWord()));
        return translateResponse;
    }
}
